package com.ruoyi.cost.service.impl;

import java.util.List;

import com.ruoyi.door.domain.HouseDoorT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cost.mapper.HouseDoorCostMapper;
import com.ruoyi.cost.domain.HouseDoorCost;
import com.ruoyi.cost.service.IHouseDoorCostService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 户资金修改Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-26
 */
@Service
public class HouseDoorCostServiceImpl implements IHouseDoorCostService
{
    @Autowired
    private HouseDoorCostMapper houseDoorCostMapper;

    /**
     * 查询户管理
     *
     * @param doorId 户管理主键
     * @return 户管理
     */
    @Override
    public HouseDoorT selectHouseDoorCostTByDoorId(Long doorId) {
        return houseDoorCostMapper.selectHouseDoorCostTByDoorId(doorId);
    }

    /**
     * 查询户管理列表
     *
     * @param houseDoorT 户管理
     * @return 户管理
     */
    @Override
    public List<HouseDoorT> selectHouseDoorTList(HouseDoorT houseDoorT) {
        return houseDoorCostMapper.selectHouseDoorTList(houseDoorT);
    }

    /**
     * 修改户管理
     *
     * @param houseDoorT 户管理
     * @return 结果
     */
    @Transactional
    @Override
    public int updateHouseDoorT(HouseDoorT houseDoorT)
    {
        HouseDoorT doorTempVO = new HouseDoorT();
        HouseDoorCost houseDoorCostT = new HouseDoorCost();
        doorTempVO = houseDoorCostMapper.selectHouseDoorCostTByHouseId(houseDoorT.getHouseId());
        int doorCostId = houseDoorCostMapper.getDoorCostId();
        houseDoorCostT.setCostMoneyPre(doorTempVO.getCostMoney());
        houseDoorCostT.setCostDatePre(doorTempVO.getCostDate());
        houseDoorCostT.setBalancePre(doorTempVO.getBalance());
        houseDoorCostT.setCreater(houseDoorT.getCreater());
        houseDoorCostT.setRemark(houseDoorT.getRemark());
        houseDoorCostT.setHouseId(houseDoorT.getHouseId());
        houseDoorCostT.setCostMoney(houseDoorT.getCostMoney());
        houseDoorCostT.setCostDate(houseDoorT.getCostDate());
        houseDoorCostT.setBalance(houseDoorT.getBalance());
        houseDoorCostMapper.insertHouseDoorCost(houseDoorCostT);
        doorTempVO.setCostMoney(houseDoorT.getCostMoney());
        doorTempVO.setCostDate(houseDoorT.getCostDate());
        doorTempVO.setBalance(houseDoorT.getBalance());
        doorTempVO.setCostId(houseDoorT.getCostId());
        houseDoorCostMapper.updateHouseCostT(doorTempVO);
        return houseDoorCostMapper.updateHouseDoorT(doorTempVO);
    }


}
